home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / µSim 1.0.5 / FabLibsƒ / FabWList.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-23  |  2.0 KB  |  93 lines  |  [TEXT/CWIE]

  1. #include    <StdLib.h>
  2. #include    "CursorBalloon.h"
  3. #include    "FabWmemman.h"
  4. #include    "FabWList.h"
  5.  
  6. typedef struct fabwlist FabWList;
  7.  
  8. struct fabwlist {
  9.     FabWList *ptr;    // next in list
  10.     DialogRef    d;        // OS window
  11.     FabWindowPtr    f;    // my data
  12.     };
  13.  
  14. FabWList    startOfWList = { nil, nil, nil };
  15.  
  16. FabWindowPtr AddWindowToList(DialogRef d)
  17. {
  18. FabWList    *newElem;
  19.  
  20. newElem = ffcalloc(sizeof(struct fabwlist) + sizeof(struct FabWindowRec));
  21. newElem->ptr = startOfWList.ptr;
  22. startOfWList.ptr = newElem;
  23.  
  24. newElem->d = d;
  25. if (GetWindowKind(d) != kDialogWindowKind)
  26.     SetWindowKind(d, kFabWindowClass);
  27.  
  28. //newElem->f = ffcalloc(sizeof(struct FabWindowRec));
  29. newElem->f = (FabWindowPtr)(newElem + 1);
  30. Zones(newElem->f) = (RgnBalloonCursHandle)NewHandle(0);
  31. // not needed because we allocate the structure with ffcalloc
  32. /*
  33. SetActivate(w, nil);
  34. SetUpdate(w, nil);
  35. SetDrag(w, nil);
  36. SetGrow(w, nil);
  37. SetZoom(w, nil);
  38. SetGoAway(w, nil);
  39. SetContent(w, nil);
  40. NumObjects(w) = 0;
  41. */
  42. return newElem->f;
  43. }
  44.  
  45. void RemoveWindowFromList(DialogRef d)
  46. {
  47. FabWList    *newElem = &startOfWList;
  48. register RgnBalloonCursHandle    tempH;
  49. register RgnBalloonCursPtr    spanPtr;
  50. register unsigned long    i;
  51.  
  52.  
  53. while (newElem->ptr) {
  54.     if (newElem->ptr->d == d) {
  55.         tempH = Zones(newElem->ptr->f);
  56.         HLock((Handle)tempH);
  57.         spanPtr = *tempH;
  58.         
  59.         for (i = 0; i < NumObjects(newElem->ptr->f); i++, spanPtr++) {
  60.             DisposeRgn(spanPtr->zoneLocal);
  61.             DisposeRgn(spanPtr->zoneGlobal);
  62. // we do nothing with the CursHandles since they might be system cursors
  63.             }
  64.         DisposeHandle((Handle)tempH);
  65. // the caller knows whether CloseWindow or CloseDialog is to be called
  66. //        ffree(newElem->ptr->f);
  67.         ffree(newElem->ptr);
  68.         newElem->ptr = newElem->ptr->ptr;
  69.         break;
  70.         }
  71.     newElem = newElem->ptr;
  72.     }
  73. }
  74.  
  75. FabWindowPtr GetFabWindowPtr(DialogRef d)
  76. {
  77. FabWList    *newElem = startOfWList.ptr;
  78.  
  79. while (newElem) {
  80.     if (newElem->d == d) {
  81.         return newElem->f;
  82.         }
  83.     newElem = newElem->ptr;
  84.     }
  85. return nil;
  86. }
  87.  
  88. void InitFabWListManager(void)
  89. {
  90. ffree(fmalloc(sizeof(struct fabwlist)));
  91. }
  92.  
  93.